hedge

fun <T> hedge(block: () -> Promise<T>, hedgeDelayMillis: Double = 100.0, maxHedges: Int = 1): Promise<T>

JS/TS-friendly facade over com.sorinirmies.arrow.resiliencekit.hedge (speculative requests): fires a duplicate attempt after a delay if the first hasn't completed yet; the first to succeed wins. block may be invoked more than once, concurrently -- it must be safe to run multiple times in parallel (e.g. an idempotent GET).

import { hedge } from "arrow-resilience-kit";

const result = await hedge(() => api.fetchData(), 50, 2);